
<h1><span class="yiyi-st" id="yiyi-12">numpy.random.set_state</span></h1>
        <blockquote>
        <p>原文：<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.set_state.html">https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.set_state.html</a></p>
        <p>译者：<a href="https://github.com/wizardforcel">飞龙</a> <a href="http://usyiyi.cn/">UsyiyiCN</a></p>
        <p>校对：（虚位以待）</p>
        </blockquote>
    
<dl class="function">
<dt id="numpy.random.set_state"><span class="yiyi-st" id="yiyi-13"> <code class="descclassname">numpy.random.</code><code class="descname">set_state</code><span class="sig-paren">(</span><em>state</em><span class="sig-paren">)</span></span></dt>
<dd><p><span class="yiyi-st" id="yiyi-14">从一个元组设置生成器的内部状态。</span></p>
<p><span class="yiyi-st" id="yiyi-15">如果有理由手动（重新）设置“Mersenne Twister”<a class="reference internal" href="#r261" id="id1">[R261]</a>伪随机数生成算法的内部状态，请使用。</span></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name">
<col class="field-body">
<tbody valign="top">
<tr class="field-odd field"><th class="field-name"><span class="yiyi-st" id="yiyi-16">参数：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-17"><strong>state</strong> : tuple(str, ndarray of 624 uints, int, int, float)</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-18"><em class="xref py py-obj">state</em>元组具有以下项：</span></p>
<ol class="arabic simple">
<li><span class="yiyi-st" id="yiyi-19">字符串&apos;MT19937&apos;，指定Mersenne Twister算法。</span></li>
<li><span class="yiyi-st" id="yiyi-20">624个无符号整数<code class="docutils literal"><span class="pre">keys</span></code>组成的1-D数组。</span></li>
<li><span class="yiyi-st" id="yiyi-21">整数<code class="docutils literal"><span class="pre">pos</span></code>。</span></li>
<li><span class="yiyi-st" id="yiyi-22">整数<code class="docutils literal"><span class="pre">has_gauss</span></code>。</span></li>
<li><span class="yiyi-st" id="yiyi-23">浮点数<code class="docutils literal"><span class="pre">cached_gaussian</span></code>。</span></li>
</ol>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name"><span class="yiyi-st" id="yiyi-24">返回：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-25"><strong>out</strong> : None</span></p>
<blockquote class="last">
<div><p><span class="yiyi-st" id="yiyi-26">成功返回“None”。</span></p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title"><span class="yiyi-st" id="yiyi-27">另见</span></p>
<p class="last"><span class="yiyi-st" id="yiyi-28"><a class="reference internal" href="numpy.random.get_state.html#numpy.random.get_state" title="numpy.random.get_state"><code class="xref py py-obj docutils literal"><span class="pre">get_state</span></code></a></span></p>
</div>
<p class="rubric"><span class="yiyi-st" id="yiyi-29">注</span></p>
<p><span class="yiyi-st" id="yiyi-30">不需要<a class="reference internal" href="#numpy.random.set_state" title="numpy.random.set_state"><code class="xref py py-obj docutils literal"><span class="pre">set_state</span></code></a>和<a class="reference internal" href="numpy.random.get_state.html#numpy.random.get_state" title="numpy.random.get_state"><code class="xref py py-obj docutils literal"><span class="pre">get_state</span></code></a>来处理NumPy中的任何随机分布。</span><span class="yiyi-st" id="yiyi-31">如果内部状态被手动改变，则用户应该准确地知道他/她正在做什么。</span></p>
<p><span class="yiyi-st" id="yiyi-32">为了向后兼容性，也接受形式(str, array of 624 uints, int)，尽管它缺少关于缓存的高斯值的一些信息：<code class="docutils literal"><span class="pre">state</span> <span class="pre">=</span> <span class="pre">(&apos;MT19937&apos;,</span> <span class="pre">keys,</span> <span class="pre">pos)</span></code>。</span></p>
<p class="rubric"><span class="yiyi-st" id="yiyi-33">参考文献</span></p>
<table class="docutils citation" frame="void" id="r261" rules="none">
<colgroup><col class="label"><col></colgroup>
<tbody valign="top">
<tr><td class="label"><span class="yiyi-st" id="yiyi-34">[R261]</span></td><td><span class="yiyi-st" id="yiyi-35"><em>(<a class="fn-backref" href="#id1">1</a>, <a class="fn-backref" href="#id2">2</a>)</em> M. Matsumoto and T. Nishimura, “Mersenne Twister: A 623-dimensionally equidistributed uniform pseudorandom number generator,” <em>ACM Trans. on Modeling and Computer Simulation</em>, Vol. </span><span class="yiyi-st" id="yiyi-36">8，No.</span><span class="yiyi-st" id="yiyi-37">1, pp.</span><span class="yiyi-st" id="yiyi-38">3-30，1998年1月。</span></td></tr>
</tbody>
</table>
</dd></dl>
